package com.risk.modules.rm.dao;

import com.risk.modules.rm.entity.Rule;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RuleDao {
    @Insert(value="INSERT INTO `rule` (`id`, `name`, `type`, `judge_type`, `judge_score`, `memo`, `data_source`, `data_interface`, `create_by`, `create_time`, `update_by`, `update_time`) " +
            "VALUES (#{rule.id}, #{rule.name}, #{rule.type}, #{rule.judgeType}, #{rule.judgeScore}, #{rule.memo}, #{rule.dataSource}, #{rule.dataInterface}, #{rule.createBy}, #{rule.createTime}, #{rule.updateBy},#{rule.updateTime})")
    int add(@Param("rule") Rule rule);

    @Select(value = "SELECT * FROM `rule` WHERE 1 = 1 and del_flag = 0 ${whereClause}  ORDER BY create_time DESC LIMIT #{0},#{1} ")
    List<Rule> pageByCondition(int start, int size, @Param("whereClause") String whereClause);

    @Select(value = "SELECT count(1) FROM `rule` WHERE 1=1 and del_flag = 0 ${whereClause}")
    int countByCondition(@Param("whereClause") String whereClause);

    @Delete(value = "UPDATE `rule` SET `del_flag` = '1' WHERE `id` = #{0}")
    int del(String id);
}
